/**
* @description : 无证户列表
* @descriptionDetail : 无证户列表
* @copyright : 浙江烟草
* @author : mc
* @create : 2022-12-05 14:54:37
*/
<template>
	<view class="page">
		<!-- #ifdef H5-ONLY -->
		<theme-navbar :is-white="false" :title="navTitle" :custom-back="goBack" style="z-index: 99999"></theme-navbar>
		<!-- #endif -->
		<view>
			<!-- 内容区 -->
			<view class="nolicence-search-lay" :style="{'top': isHideNav ? 0 : '44px'}">
				<u-search shape="round" :clearabled="true" :showAction="true" actionText="确定" :animation="true" :placeholder="placeholder" v-model="keyword" @custom="searchClick"></u-search>
			</view>
			<me-table :i="0" :index="0" :initLoad="false" :load-data="loadData" :top="getListViewTop()" ref="mescrollItem0" class="content-list">
				<view slot-scope="d" class="re-list">
					<u-row>
						<u-col :span="spanVal">
							<infocard class="card-view" :info="d.data" @click.native="showDetail(d.data.retailerUuid)" />
						</u-col>
					</u-row>
				</view>
			</me-table>
		</view>
	</view>
</template>

<script>
	import meTable from '@/components/me-table.vue';
	import infocard from './components/infocard.vue';
	import queryService from '@/service/check/query.service';
	import MescrollMoreMixin from '@/components/mescroll-uni/mixins/mescroll-more.js';
	import {
		SET_MAP_LAT_LON,
	} from '@/config/setting.config.js';
	export default {
		components: {
			infocard,
			meTable,
		},
		mixins: [MescrollMoreMixin, ], // 注意此处还需使用MescrollMoreItemMixin (必须写在MescrollMixin后面)
		data() {
			return {
				keyword: '', // 查询关键字
				spanVal: 12,
				firstNoLoad: false,
				title: '无证户查询',
				placeholder: '请输入无证户姓名', // 搜索框提示语句
				dataList: [],
				upOption: {
					page: {
						size: 10, // 每页数据的数量,默认10
					},
					noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					empty: {
						tip: '暂无相关数据',
					},
				},
				isInterview: '', //默认进来是非走访按钮点击进来的（修改于2023-11-19，辽宁新加特例）
			};
		},
		onLoad(options) {
			if (options.isInterview) {
				this.isInterview = options.isInterview
			}
		},
		methods: {
			goInterview(row) {
				this.$u.route('pages/interview/visit/inspect', {
					retailerUuid: row.retailerUuid,
					taskSubject: '02' // 01是零售户 02是无证户
				});
			},
			/**
			 * @description 筛选按钮点击事件
			 */
			searchClick() {
				let mescroll = this.getMescroll(this.tabIndex);
				mescroll.triggerDownScroll();
			},
			/**
			 * @description 点击信息跳转详情
			 * @params retailerUuid 主键
			 */
			showDetail(retailerUuid) {
				// 定义跳转参数
				const params = {
					retailerUuid,
				};
				this.setRouteParam(params);
				this.$u.route('/pages/query/nolicence/detailUnlicense');
			},
			getListViewTop() {
				let p = uni.upx2px(64) + uni.upx2px(10) + 19;
				return p + 'px';
			},
			updateBackState(param) {
				this.getMescroll(this.tabIndex).triggerDownScroll();
			},
			longLatit() {
				let self = this;
				return new Promise((resolve) => {
					if (this.$deviceApi.geolocation) {
						this.$deviceApi.geolocation().then((res) => {
							self.longitude = res.longitude;
							self.latitude = res.latitude;
							resolve();
						});
					} else {
						self.longitude = SET_MAP_LAT_LON[0];
						self.latitude = SET_MAP_LAT_LON[1];
						resolve();
					}
				});
			},
			loadData(page) {
				this.longLatit();
				let self = this;
				let param = {
					managerName: this.keyword,
				};
				return new Promise((resolve) => {
					// if (!this.firstNoLoad) {
					// 	this.firstNoLoad = true;
					// 	resolve({
					// 		count: 0,
					// 		data: [],
					// 	});
					// 	return;
					// }
					this.longLatit().then(() => {
						param.latitudeLeft = self.latitude;
						param.longitudeLeft = self.longitude;
						queryService
							.unlicenseList(page.num, page.size, param)
							.then((res) => {
								if (res.success) {
									resolve({
										count: res.count,
										data: [...res.data, ],
									});
								} else {
									resolve({
										count: 0,
										data: [],
									});
								}
							})
							.catch((e) => {
								resolve({
									count: 0,
									data: [],
								});
							});
					});
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.page {
		padding: 0;
	}

	.content-list {
		background-color: #f3f4f5;
	}

	.re-list {
		margin: 20rpx;
		background-color: #fff;
		border-radius: 12px;
		padding: 14rpx 8rpx;
	}

	.nolicence-search-lay {
		background-color: #fff;
		position: fixed;
		// #ifndef H5-DINGDING
		top: 44px;
		// #endif
		// #ifdef H5-DINGDING
		top: 0px;
		// #endif
		z-index: 99;
		width: 100%;
		padding: $cm-search-padding-row $cm-search-padding-column;
	}

	.option-btn {
		display: flex;
		flex-direction: column;
		border-left: 4rpx solid #f2f3f6;

		.opt-item {
			margin-bottom: 30rpx;
		}
	}
</style>